const state = {
	token: null,
	userInfo: null
};

const mutations = {
	SET_USER_INFO(state, value) {
		if (!value.token) {
			value.token = uni.getStorageSync('token') || '';
		}
		state.userInfo = value;
		uni.setStorageSync('token', value.token);
		uni.setStorageSync('userInfo', value);
	},

	REMOVE_USER_INFO(state) {
		state.userInfo = {};
		uni.removeStorageSync('token');
		uni.removeStorageSync('userInfo');
	}
};

const actions = {};

export default {
	namespaced: true,
	state,
	mutations,
	actions
};
